package
{
	import core.Model;
	import core.manager.SoundManager;
	import core.events.GameEvent;
	
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	
	public class InsurancePanel extends MovieClip
	{
		public var yesBtn:SimpleButton;
		
		public var noBtn:SimpleButton;
		
		public var allYesBtn:SimpleButton;
		
		public var allNoBtn:SimpleButton;
		
		public var neverBtn:SimpleButton;
		
		public var type:int = -1;
		
		public function InsurancePanel()
		{
			super();
			this.addEventListener(MouseEvent.CLICK,clickHandler);
			SoundManager.instance.play("errorMessage");
		}
		
		private function clickHandler(event:MouseEvent):void {
			var targetName:String = event.target.name;
			if(targetName == "yesBtn"){
				type = 1;
			}else if(targetName == "allYesBtn"){
				type = 2;
			}else if(targetName == "noBtn"){
				type = 3;
			}else if(targetName == "allNoBtn"){
				type = 4;
			}else if(targetName == "neverBtn"){
				type = -1;
				Model.instance.insureMode = -1;
			}
			this.dispatchEvent(new GameEvent(GameEvent.SET_INSURE_TYPE));
		}
		
		public function dispose():void {
			this.removeEventListener(MouseEvent.CLICK,clickHandler);
			if(this.parent){
				this.parent.removeChild(this);
			}
		}
	}
}